package other;

import java.util.Arrays;

public class quick {
    public static void main(String[] args) {
        int[] arr = {3, 67, 8, 4, 1, 8, 0, 5, 3, 7, 3, 2};
        quickSort(0, arr.length - 1, arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void quickSort(int low, int high, int[] arr) {
        if (low < high) {
            int index = partition(low, high, arr);
            quickSort(low, index - 1, arr);
            quickSort(index + 1, high, arr);
        }

    }

    public static int partition(int low, int high, int[] arr) {
        int temp = arr[low];
        while (low < high) {
            while (arr[high] >= temp && low < high) {
                high--;
            }
            arr[low] = arr[high];
            while (arr[low] <= temp && low < high) {
                low++;
            }
            arr[high] = arr[low];
        }
        arr[low] = temp;
        return low;
    }
}
